package api

import "encoding/json"

type Result struct {
	Code int    `json:"code"`
	Data string `json:"data"`
	Err  string `json:"err"`
}

func SuccessResult(data string) []byte {
	result := &Result{
		Code: 200,
		Data: data,
	}
	bytes, _ := json.Marshal(result)
	return bytes
}

func FailResult(err string) []byte {
	result := &Result{
		Code: -1,
		Err:  err,
	}
	bytes, _ := json.Marshal(result)
	return bytes
}
